from random import randint
class Boxer:
    def __init__(self,name):
        self.name = name
        self.life = 100
        self.pet = None
    def intro(self):
        if self.pet == None:
            print('my name is {},and I hate dog '.format(self.name))
        else:
            print('my name is {},and I have a dog {}'.format(self.name,self.pet.name))
    def punch(self):
        side = randint(0,1)
        print('{} puch in {} '.format(self.name,side),end='--->')
        return side
    def dodge(self):
        side = randint(0,1)
        print('{} dodge in {}'.format(self.name,side) )
        return side
    def adopt(self,dog):
        self.pet = dog
        dog.adopted(self)
    def show(self):
        print('{}={}'.format(self.name,self.life))
    
class Dog:
    def __init__(self,pname,prace):
        self.name = pname
        self.race = prace
        self.owner = None
    def bite(self,person):
        print('{} is biting {}'.format(self.name,person.name))
        person.life = person.life - 5
    def adopted(self,powner):
        self.owner = powner
    def intro(self):
        if self.owner == None:
            print('wangwang, my name is {}, I want a hoster'.format(self.name))
        else:
            print('wangwang, my name is {}, my owner is {}'.format(self.name,self.owner.name))
    



b1 = Boxer('Ali')
b2 = Boxer('tenson')
b1.intro()

d1 = Dog('xiaohua','hashiqi')
d1.intro()

b1.adopt(d1)

b1.pet.bite(b1)
b1.show()

for i in [b1,b2]:
    print("\n{:*^30s}".format(i.name))
    print('name: id ={} value = {}'.format(id(i.name),i.name))
    print('life: id ={} value = {}'.format(id(i.life),i.life))
    print('pet: id ={} value = {}'.format(id(i.pet),i.pet))
    print('punch: id ={} value = {}'.format(id(i.punch),i.punch))
    print('intro: id ={} value = {}'.format(id(i.intro),i.intro))

